package com.sample.service;

import com.sample.dao.UserDao;
import com.sample.entity.User;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Keyon
 * @Date 2019/11/29 13:55
 * @Desc 用户-业务层
 */
@Log4j
@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    public List<User> findAll() {
        List<User> userList = userDao.findAll();

        return userList;
    }

    public void saveUser(String userName, String email) {
        User user = new User();
        user.setUserName(userName);
        user.setEmail(email);
        log.info("saveUser: " + user.toString());
        userDao.saveUser(user);
    }

    public User findUserById(Integer id) {
        User user = userDao.findUserById(id);
        return user;
    }

}
